﻿function ChamadaAjax(metodo, callback, pars, loading) {

    url = window.location.pathname + "/" + metodo;
    loading == undefined ? loading = true : loading = loading;
    if (!pars) pars = {};

    $.ajax({
        type: "POST",
        url: url,
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify(pars),
        dataType: "json",
        cache: false,
        global: loading,
        success: callback,
        error: function (xml, status) {
            /*if ((status == 'error') || (status == "")) {
            try {
            var json = eval('(' + xml.responseText + ')');
            trataExcecao(json);
            } catch (e) { }
            } else {
            alert(status);
            }*/
            alert("Não foi possível realizar a operação");
        }
    });
}